﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BizTalk.ESB.Extensions.Helpers
{
   
    [Serializable]
    public class Logging
    {
        public static void logEventViewer(string Source, string Text, System.Diagnostics.EventLogEntryType evtType)
        {
            try
            {
                if (!System.Diagnostics.EventLog.SourceExists(Source))
                {
                    System.Diagnostics.EventLog.CreateEventSource(Source, "Application");
                }

                if (Text.Length > 32000)
                {
                    System.Diagnostics.EventLog.WriteEntry(Source, Text.Substring(0, 32000), evtType);
                }
                else
                {
                    System.Diagnostics.EventLog.WriteEntry(Source, Text, evtType);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.WriteLine("LOGGING EXCEPTION -- " + e.ToString());
            }
        }


    }

}
